package com.bgq365.study.springboot2.boot02web.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Controller
public class FileController {

    @GetMapping("/file.page")
    public String file() {
        return "file_layout";
    }

    @PostMapping("/upload")
    public String upload(@RequestParam(value = "username",required = true) String username,
                         @RequestParam String email,
                         @RequestPart("headImg") MultipartFile headImg,
                         MultipartFile[] lifeImages) {
        log.info("upload request params:" + username + "," + email + "," + headImg.getSize() + "，" + lifeImages.length);
        return "redirect:file.page";
    }
}
